package com.satoken.Entity;

import java.util.Objects;

public enum CodeEnum {
    OK("200", "成功"),
    ACCOUNT_ERROR("300", "账号或密码错误"),
    PARAM_ERROR("301", "参数为空或不规范"),
    TOKEN_ERROR("400", "token错误或已失效"),
    NO_LOGIN("401", "未登录"),
    SYS_ERROR("500", "系统异常");

    private String code;
    private String msg;

    CodeEnum(String code,String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    // 根据code返回msg信息
    public String getMsgByCode(String code) {
        for (CodeEnum entry : CodeEnum.values()) {
            if (Objects.equals(entry.getCode(), code)) {
                return entry.getMsg();
            }
        }
        return null;
    }

}
